<?php

require_once 'Ext/User/Action/Edit/Password/Abstract.php';

class Ext_User_Action_Edit_Password_Adapter_Db extends Ext_User_Action_Edit_Password_Abstract
{
    public function editPassword($password)
    {
        $_appModelDbTableUserAccountBase = App_Model_DbTable_User_Account_Base::getInstance();
	    $_userAccountBase = $_appModelDbTableUserAccountBase->getRowByUserId($this->_userId);
        if(!$_userAccountBase)
        {
            $_result = $this->setResult(Ext_User_Action_Edit_Password_Result::FAILURE);
            return $_result;
        }
        
        $row = array(
            'password' => md5($password),
        );
        $_appModelDbTableUserAccountBase->addOld($row, $this->_userId);

        $_result = $this->setResult(Ext_User_Action_Edit_Password_Result::SUCCESS);
        return $_result;
    }
}
